home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------ */
- /* These are my modified startup routines */
- /* ------------------------------------------ */
-
- /* entnommen von QuickReq.c, von FishDisk ??? */
-
- /* --------------------- source code revisions, tracked by rcs ---------- */
-
- /* $Header: Hard0:C-Compiler/src/routinen/rcs/_main.c,v 1.1 91/08/19 11:19:13 Mtwx Exp Locker: Mtwx $ */
- /* $Log: _main.c,v $
- * Revision 1.1 91/08/19 11:19:13 Mtwx
- * Initial revision
- * */
-
- /* ------------------------------- includes ----------------------------- */
-
- #include <exec/types.h>
- #include <stdio.h>
-
- #define MAXARG 32
- #define QUOTE '"'
-
- VOID _main(line)
- register char *line;
- {
- int argc = 0; /* arg count */
- char *argv[MAXARG]; /* arg pointers */
-
- argc = ParseCommands(0, line, argv);
- if(argc > MAXARG)
- XCEXIT(1);
-
- main(argc, argv);
- XCEXIT(0);
- }
-
- /* I have separated this to own routine, because I also use this to parse
- redirection file.
- */
-
- int ParseCommands(int Start, register char *line, char *args[])
- {
- register char **pargv;
- int argc;
-
- argc = Start;
-
- while (argc < MAXARG)
- {
- while (isspace(*line)) line++;
- if (*line == '\0') break;
- pargv = &args[argc++];
- if (*line == QUOTE)
- {
- *pargv = ++line; /* ptr inside quoted string */
- while ((*line != '\0') && (*line != QUOTE)) line++;
- if (*line == '\0') {
- return(MAXARG+1);
- }
- else *line++ = '\0'; /* terminate arg */
- }
- else /* non-quoted arg */
- {
- *pargv = line;
- while ((*line != '\0') && (!isspace(*line))) line++;
- if (*line == '\0') break;
- else *line++ = '\0'; /* terminate arg */
- }
- } /* while */
-
- return(argc);
- }
-